package com.ruoyi.mobile.project.pms.service;

import com.github.pagehelper.PageHelper;
import com.ruoyi.db.pms.domain.PmsCategory;
import com.ruoyi.db.pms.domain.query.PmsCategoryQueryVo;
import com.ruoyi.db.pms.mapper.PmsCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class WxPmsCategoryService
{
    @Autowired
    private PmsCategoryMapper categoryMapper;

    public List<PmsCategory> queryL1WithoutRecommend(int offset, int limit)
    {
        PageHelper.startPage(offset, limit);
        return categoryMapper.selectL1WithoutRecommendCategoryList();
    }

    public List<PmsCategory> queryL1(int offset, int limit)
    {
        PageHelper.startPage(offset,limit);
        return categoryMapper.selectL1WithoutRecommendCategoryList();
    }

    public List<PmsCategory> queryL1()
    {
        return categoryMapper.selectL1WithoutRecommendCategoryList();
    }

    public List<PmsCategory> queryByPid(Long pid)
    {
        PmsCategoryQueryVo categoryQueryVo = new PmsCategoryQueryVo();
        categoryQueryVo.setParentId(pid);

        return categoryMapper.selectPmsCategoryList(categoryQueryVo);
    }

    /**
     * 通过获取的类目id获得二级类目列表
     *
     * @author 张涛
     * @param ids
     * @return
     */
    public List<PmsCategory> queryL2ByIds(List<Long> ids)
    {
        PmsCategoryQueryVo categoryQueryVo = new PmsCategoryQueryVo();
        categoryQueryVo.setIds(ids);
        categoryQueryVo.setLevel("L2");
        return categoryMapper.selectPmsCategoryL2List(categoryQueryVo);
    }

    /**
     * 根据id获取商品分类
     *
     * @author 毛思淼
     * @param id
     * @return
     */
    public PmsCategory findById(Long id)
    {
        return categoryMapper.selectPmsCategoryById(id);
    }

    public List<PmsCategory> querySelective(String id, String name, Integer page, Integer size, String sort, String order)
    {
        return null;
    }

    public int updateById(PmsCategory category)
    {
        return 0;
    }

    public void deleteById(Long id)
    {

    }

    public void add(PmsCategory category)
    {

    }

    public List<PmsCategory> queryChannel()
    {
        PmsCategoryQueryVo categoryQueryVo = new PmsCategoryQueryVo();
        categoryQueryVo.setLevel("L1");

        return categoryMapper.selectPmsCategoryList(categoryQueryVo);
    }
}
